import React,{ PureComponent, CSSProperties } from "react"
import { Button } from 'antd-mobile';
import MAction from '../MAction/MAction';
// import MAction = require("../MAction/MAction");//ts tsx文件中 需要这么导入 export default的模块(自己写的)
import { isNull } from "util";
enum ButtonSize {
	small = "small",
	large = "large"
}
interface Props {
	label: string,
	size?: ButtonSize,
	event_key?: string,
	formData: Object,
	style?: CSSProperties,
	wrapperStyle?: CSSProperties
}
interface State {

}
export default class MiButton extends PureComponent<Props, State> {
	public readonly state:Readonly<State> = {//将state中的参数设为只读，防止this.state.xxx=xx;的写法，只能通过this.setState修改

	}
	public render() {
		let { wrapperStyle, style, formData, event_key, size, label } = this.props;
		if (isNull(size)) {
			style = {
				height: "40px",
				lineHeight: "37px",
				fontSize: "14px",
				borderRadius: "10px",
				...style
			}
		}
		else {
			style = {
				...style
			}
		}

		return (
			<div style={{ ...wrapperStyle }}>
				<Button
					size={size}
					style={{ ...style }}
					onClick={() => {
						MAction({ ...this.props, formData }, event_key);
					}}
				>
					{label}
				</Button>
			</div>
		)
	}
}